<template>
  <div>
    <div id="mychart"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  methods: {
    // 基本柱形图
    change() {
      const chartBox = this.$echarts.init(document.getElementById("mychart"));
      const option = {
        xAxis: {
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {},
        grid: {
          top: "12%",
          left: "3%",
          right: "3%",
          bottom: "0%",
          containLabel: true,
        },
        series: [
          {
            type: "bar",
            data: [23, 24, 18, 25, 27, 28, 25],
          },
        ],
      };
      chartBox.setOption(option);
      // 根据页面大小自动响应图表大小
      window.addEventListener("resize", function () {
        chartBox.resize();
      });
    },
  },
  mounted() {
    this.change();
  },
};
</script>

<style lang="scss" scoped>
#mychart {
  width: 100%;
  height: 316px;
}
</style>
